package beautiful.butterfly.distributed_task_processing_engine.task_manage;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import java.io.File;


public class DistributedTaskProcessingEngineServlet extends HttpServlet
{
    private static final long serialVersionUID = 1L;
    public static ApplicationContext applicationContext = null;

    public void init() throws ServletException
    {

        try
        {
            //临时的spring初始化
            String beansXmlPath = getServletContext().getRealPath("") + "/WEB-INF/classes" + File.separator + "beans.xml";
            applicationContext = new FileSystemXmlApplicationContext(beansXmlPath);
            String configFilePath = getInitParameter("configFilePath");
            DistributedTaskProcessingEngine.setConfigFilePath(configFilePath);
            DistributedTaskProcessingEngine.initial();
        } catch (Exception e)
        {
            throw new ServletException(e);
        }
    }
}
